// void, Obj This 
// cmdparam is like this ReqSet, <research>, ReqPlr, <research>, SetsPlr, <env>, <value>, SetsSet, <env>, <value>, NamePlr, <research>, NameSet, <research>

str dest, name, token;
Building this;
this = This.AsBuilding();
dest = cmdparam;

EnvWriteString(this, "researching", "yes");

while(dest != "")
{
	token = ParseStr(dest, dest);
	if(token == "NamePlr")
	{
		name = ParseStr(dest, dest);
                
		EnvWriteString(.player, name, "researching");
		if (name == "Tribute") {
			Building th;
			th = .settlement.GetCentralBuilding;
			th.GlobalSpellStart(gsTribute, .player);
			EnvWriteObj(.player, "TributeBuilding", th);
			PlaySound("data/Sound Entities/StonehengeSpell.xml");
		}
		break;
	}
	if(token == "NameSet")
	{
		name = ParseStr(dest, dest);
		EnvWriteString(.settlement, name, "researching");
		break;
	}
}

.Progress();

if(name == "Outpost Level 1" || name == "Outpost Level 2"){
	if(.settlement.GetCentralBuilding.IsHeirOf("Outpost")){
		if(.maxhealth == 10000)
			.SetMaxHealth(20000);
		else if(.maxhealth == 20000)
			.SetMaxHealth(30000);
		else if(.maxhealth == 30000)
			.SetMaxHealth(40000);
		else if(.maxhealth == 40000)
			.SetMaxHealth(50000);
				
		.SetHealth(.health + 5000);
	}
}

if(name == "Gate Level 1" || name == "Gate Level 2"){
	if(.IsHeirOf("Gate")){
		if(.AsGate.maxhealth == 5000)
			.AsGate.SetMaxHealth(15000);
		else if(.AsGate.maxhealth == 15000)
			.AsGate.SetMaxHealth(25000);
		else if(.AsGate.maxhealth == 25000)
			.AsGate.SetMaxHealth(35000);
		else if(.AsGate.maxhealth == 35000)
			.AsGate.SetMaxHealth(45000);
		else if(.AsGate.maxhealth == 45000)
			.AsGate.SetMaxHealth(55000);

		.AsGate.SetHealth(.health + 5000); 
	}
}

PlaySound(.player, "data/Sounds Entities/UpgradeComplete.xml");
